// ==UserScript==
// @name         TG点击页面自动复制内容
// @namespace    http://tampermonkey.net/
// @version      2024-07-24
// @description  try to take over the world!
// @author       You
// @match        https://web.telegram.org/k/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=telegram.org
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
if(wmyqq_dom_all) {
    document.body.removeChild(document.querySelector('.wmyqq_dom_all'))

}
var wmyqq_dom_all=document.createElement('div');
wmyqq_dom_all.className = 'wmyqq_dom_all';
wmyqq_dom_all.style.position = 'absolute';
wmyqq_dom_all.style.top = '0';
wmyqq_dom_all.style.left = '0px';
wmyqq_dom_all.style.width = '40%';
wmyqq_dom_all.style.height = '200px';
wmyqq_dom_all.style.backgroundColor = 'rgba(255,255,255,0.5)';
wmyqq_dom_all.style.border = '1px solid #000';
wmyqq_dom_all.style.zIndex = 999;
document.body.appendChild(wmyqq_dom_all);

var wmyqq_dom_switch=document.createElement('button');
wmyqq_dom_switch.innerText = '切换';
wmyqq_dom_switch.style.width = '80px';
wmyqq_dom_switch.style.height = '30px';
let wmyqq_is_show = true;
wmyqq_dom_switch.onclick=()=>{
    wmyqq_is_show = !wmyqq_is_show;
    wmyqq_dom_all.style.height = wmyqq_is_show ? '500px' : '50px';
    wmyqq_dom_all.style.width = wmyqq_is_show ? '50%' : '100px';
}


var wmyqq_dom_input=document.createElement('textarea');
wmyqq_dom_input.style.width = '100%';
wmyqq_dom_input.style.height = 'calc(100% - 50px)';

wmyqq_dom_all.appendChild(wmyqq_dom_switch)
wmyqq_dom_all.appendChild(wmyqq_dom_input)
function find_parent_class(p_dom,p_class_name){
    if(p_dom.className == p_class_name)return true;
    if(p_dom.parentNode == null)return false;
    return find_parent_class(p_dom.parentNode,p_class_name);
}


window.addEventListener('click',(e)=>{
    if(find_parent_class(e.target,'wmyqq_dom_all'))return;
    wmyqq_dom_input.value = e.target.innerText    ;
})
    // Your code here...
})();